Use case: SMARTCARD TX IT process

Sequence diagram

SMARTCARD transmit IT process

  @startuml
  participant " Application" as p1
  participant "HAL SMARTCARD driver" as p2
  participant "SMARTCARD_IRQHandler" as p3

  == initialization and configuration ==
  == Smartcard HAL Transmit IT ==

  p1->p2: <color: green> HAL_SMARTCARD_Transmit_IT(&hsmartcard, aTxBuffer, DATA_TO_SEND_SIZE)
  note over p2 #00FF00
  Transmitting data ongoing
  end note
  p2-->p1: HAL_OK
  p3<-: SMARTCARD data interrupt
  p3->p2: HAL_SMARTCARD_IRQHandler
  note over p2 #FFFF99
  All data (Size == hsmartcard->TxXferCount) have been transmitted
  end note
  note over p2 #00FF00
  End of transmitting data
  end note
  p2->p1: HAL_SMARTCARD_TxCpltCallback(hsmartcard->TxXferCount)

  @enduml

Code snippet

HAL1

HAL2

#define DATA_TO_SEND_SIZE       256

uint8_t aTxBuffer[DATA_TO_SEND_SIZE] = " **** Smartcard Communication **** ";

SMARTCARD_HandleTypeDef hsmartcard;


/* Ensure that all required peripherals
  (USART, GPIO, NVIC etc.) are configured properly
/*
...
*/

/* Smartcard register Transmit complete user callback */
HAL_SMARTCARD_RegisterCallback(&hsmartcard, HAL_SMARTCARD_TX_CB_ID,
                               Smartcard_TxCpltCallback);

/* Start a Smartcard Process in interruption mode */
HAL_SMARTCARD_Transmit_IT(&hsmartcard, aTxBuffer,
                        DATA_TO_SEND_SIZE);
#define DATA_TO_SEND_SIZE       256

uint8_t aTxBuffer[DATA_TO_SEND_SIZE] = " **** Smartcard Communication **** ";

hal_smartcard_handle_t hsmartcard;


/* Ensure that all required peripherals
  (USART, GPIO, NVIC etc.) are configured properly
/*
...
*/

/* Smartcard register Transmit complete user callback */
HAL_SMARTCARD_RegisterTxCpltCallback(&hsmartcard, Smartcard_TxCpltCallback);


/* Start a Smartcard Process in interruption mode */
HAL_SMARTCARD_Transmit_IT(&hsmartcard, aTxBuffer,
                        DATA_TO_SEND_SIZE);

Key changes

  1. HAL2 uses the SMARTCARD handle type hal_smartcard_handle_t.

  2. HAL2 provides a dedicated transmit-complete callback registration API (HAL_SMARTCARD_RegisterTxCpltCallback).